package com.hiray.viewtouchevent;

import android.graphics.Rect;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;

public class ScrollTestActivity extends AppCompatActivity {
    private static final String TAG = "ScrollTestActivity";
    Button view;
    FrameLayout root;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_scroll_test);
        view = findViewById(R.id.text_view);
        root = findViewById(R.id.root);
        root.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Rect rect = new Rect();
                root.getDrawingRect(rect);
                Log.i(TAG, "onClick: " + rect);
                root.scrollBy(0, 10);
            }
        });
        findViewById(R.id.scroll_button)
                .setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        view.scrollBy(10, 0);
                    }
                });
    }

}
